package cn.cttic.order.dubbo;

import cn.cttic.order.api.RemoteSaleOrderService;
import cn.cttic.order.api.domain.BaseSaleOrder;
import cn.cttic.order.api.domain.vo.BaseSaleOrderVo;
import cn.cttic.order.mapper.BaseSaleOrderMapper;
import cn.cttic.order.service.IBaseSaleOrderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

@DubboService
@Slf4j
@RequiredArgsConstructor
public class RemoteSaleOrderServiceImpl implements RemoteSaleOrderService {

    private final BaseSaleOrderMapper baseSaleOrderMapper;

    /**
     * 根据产品套餐查询所有的订单
     *
     * @param productId 产品套餐ID
     * @return
     */
    @Override
    public List<BaseSaleOrderVo> getSaleOrderListByProductId(String productId) {
        return baseSaleOrderMapper.selectVoList(
            new LambdaQueryWrapper<BaseSaleOrder>()
                .eq(BaseSaleOrder::getProductId, productId)
        );
    }
}
